<blockquote class="layui-elem-quote">
    <div class="layui-inline">
        <i class="layui-icon layui-icon-list layui-head-icon"></i>
        <span class="layui-font-16 layui-font-green">基础配置</span>
    </div>
</blockquote>
<div class="layui-card">
    <div class="layui-card-body">
        <!-- <form class="layui-form"> -->
        <div class="layui-tab">
            <ul class="layui-tab-title">
                <li class="layui-this">用户协议</li>
                <li>隐私权限</li>
                <li>提现协议</li>
                <li>APP版本管理</li>
                <li>分润设置</li>
                <li>其他配置</li>
            </ul>
            <!-- <form> -->
            <div class="layui-tab-content">
                <div class="layui-tab-item layui-show">
                    <form class="layui-form">
                        <div class="layui-form-item">
                            <label class="layui-form-label">用户协议</label>
                            <div class="layui-input-block">
                                <textarea name="user_agreement"
                                    id="user_agreement">{$row.user_agreement|default=''}</textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="t1">保存配置</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="layui-tab-item">
                    <form class="layui-form">
                        <div class="layui-form-item">
                            <label class="layui-form-label">隐私权限</label>
                            <div class="layui-input-block">
                                <textarea name="privacy_permission"
                                    id="privacy_permission">{$row.privacy_permission|default=''}</textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="t2">保存配置</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="layui-tab-item">
                    <form class="layui-form">
                        <div class="layui-form-item">
                            <label class="layui-form-label">提现协议</label>
                            <div class="layui-input-block">
                                <textarea name="withdrawal_agreement"
                                    id="withdrawal_agreement">{$row.withdrawal_agreement|default=''}</textarea>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="t3">保存配置</button>
                            </div>
                        </div>
                    </form>
                </div>
                <div class="layui-tab-item">
                    <form class="layui-form">
                        <div class="layui-form-item">
                            <label class="layui-form-label">版本号</label>
                            <div class="layui-input-block">
                                <input type="text" name="version" value="{$row.version|default=''}"
                                    lay-verify="required" placeholder="" autocomplete="off" class="layui-input">

                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">APP包</label>
                            <div class="layui-input-block">
                                <input type="text" id="app_path" name="app_path" value="{$row.app_path|default=''}"
                                    lay-verify="required" placeholder="" autocomplete="off" class="layui-input">

                                <button type="button" class="layui-btn" id="uploadExample">
                                    <i class="layui-icon">&#xe67c;</i>上传安装包
                                </button>
                            </div>
                        </div>

                        <div class="layui-form-item">
                            <label class="layui-form-label">APP更新包(wgt)</label>
                            <div class="layui-input-block">
                                <input type="text" id="app_path_wgt" name="app_path_wgt"
                                    value="{$row.app_path_wgt|default=''}" lay-verify="required" placeholder=""
                                    autocomplete="off" class="layui-input">

                                <button type="button" class="layui-btn" id="uploadExampleWgt">
                                    <i class="layui-icon">&#xe67c;</i>上传更新包
                                </button>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">更新描述:</label>
                            <div class="layui-input-block">
                                <textarea id="app_up_tips" lay-verify="required" style="width: 775px;"
                                    placeholder="请输入更新内容" autocomplete="off" name="app_up_tips"
                                    class="layui-textarea">{$row.app_up_tips|default=''}</textarea>
                                <div>多行请【;】分隔</div>
                            </div>
                        </div>
                        <br />
                        <hr />
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="t4">保存配置</button>
                            </div>
                        </div>

                    </form>
                </div>

                <div class="layui-tab-item">
                    <!-- <br /> -->
                    <hr />
                    <form class="layui-form">
                        <fieldset class="layui-elem-field">
                            <legend>现金分润分配比例:</legend>
                            <div class="layui-form-item">
                                <label class="layui-form-label">代理比例：</label>
                                <div class="layui-input-block">
                                    <input type="number" name="cash_agent_ratio"
                                        value="{$row.cash_agent_ratio|default=''}" placeholder="" autocomplete="off"
                                        class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">商户比例：</label>
                                <div class="layui-input-block">
                                    <input type="number" id="cash_shop_ratio" name="cash_shop_ratio"
                                        value="{$row.cash_shop_ratio|default=''}" lay-verify="required" placeholder=""
                                        autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </fieldset>
                        <br />
                        <hr />
                        <fieldset class="layui-elem-field">
                            <legend>广告分润分配比例:</legend>
                            <div class="layui-form-item">
                                <label class="layui-form-label">代理比例：</label>
                                <div class="layui-input-block">
                                    <input type="number" name="advertising_agent_ratio"
                                        value="{$row.advertising_agent_ratio|default=''}" placeholder="" autocomplete="off"
                                        class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">商户比例：</label>
                                <div class="layui-input-block">
                                    <input type="number" id="advertising_shop_ratio" name="advertising_shop_ratio"
                                        value="{$row.advertising_shop_ratio|default=''}" lay-verify="required" placeholder=""
                                        autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </fieldset>
                        <br />
                        <hr />
                        <fieldset class="layui-elem-field">
                            <legend>产品分润分配比例:</legend>
                            <div class="layui-form-item">
                                <label class="layui-form-label">代理比例：</label>
                                <div class="layui-input-block">
                                    <input type="number" name="product_agent_ratio"
                                        value="{$row.product_agent_ratio|default=''}" placeholder="" autocomplete="off"
                                        class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">商户比例：</label>
                                <div class="layui-input-block">
                                    <input type="number" id="product_shop_ratio" name="product_shop_ratio"
                                        value="{$row.product_shop_ratio|default=''}" lay-verify="required" placeholder=""
                                        autocomplete="off" class="layui-input">
                                </div>
                            </div>
                        </fieldset>

                        <br />
                        <!-- <hr /> -->
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="t5">保存配置</button>
                            </div>
                        </div>

                    </form>
                </div>

                <div class="layui-tab-item">
                    <form class="layui-form">
                        <div class="layui-form-item">
                            <label class="layui-form-label">VIP代理金额:</label>
                            <div class="layui-input-block">
                                <input type="number" id="vip_agent_price" name="vip_agent_price"
                                value="{$row.vip_agent_price|default=''}" lay-verify="required" placeholder=""
                                autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">产品分润总比例:</label>
                            <div class="layui-input-block">
                                <input type="number" id="product_bili" name="product_bili"
                                value="{$row.product_bili|default=''}" lay-verify="required" placeholder=""
                                autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <!-- <div class="layui-form-item">
                            <label class="layui-form-label">VIP代理金额:</label>
                            <div class="layui-input-block">
                                <input type="number" id="vip_agent_price" name="vip_agent_price"
                                value="{$row.vip_agent_price|default=''}" lay-verify="required" placeholder=""
                                autocomplete="off" class="layui-input">
                            </div>
                        </div> -->
                        <div class="layui-form-item">
                            <div class="layui-input-block">
                                <button class="layui-btn" lay-submit lay-filter="t6">保存配置</button>
                            </div>
                        </div>
                    </form>
                </div>

            </div>
            <!-- <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="aliPayForm">保存配置</button>
                    </div>
                </div> -->
            <!-- </form> -->
        </div>
        <!-- </form> -->
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        tinymce.init({
            selector: '#user_agreement,#privacy_permission,#withdrawal_agreement',
            language: 'zh_CN',
            plugins: 'preview image  emoticons table link hr anchor fullscreen lists',
            toolbar: 'bold italic underline strikethrough alignleft aligncenter alignright alignjustify indent outdent numlist bullist ' +
                'fontselect fontsizeselect forecolor backcolor blockquote removeformat ' +
                'emoticons image link hr anchor fullscreen preview',
            images_upload_url: '/store/upload/layedit',
            min_height: 500,
            setup: function (editor) {
                editor.on('change', function () {
                    editor.save();
                });
            },
        });
    })
    layui.use(['form', 'upload'], function () {
        var form = layui.form;
        var upload = layui.upload;
        var index = 0;

        var uploadInstWgt = upload.render({
            elem: '#uploadExampleWgt' //绑定元素
            , url: '/store/upload/uploadWgt' //上传接口
            , accept: 'file'
            , before: function () {
                index = layer.load(1);
            }
            , done: function (res) {
                layer.close(index);
                if (res.code = 1) {
                    $("#app_path_wgt").val(res.location);
                    layer.msg('上传成功');
                } else {
                    layer.msg('上传失败');
                }
            }
            , error: function () {
                layer.close(index);
                layer.msg('上传失败');
            }
        });


        var uploadInst = upload.render({
            elem: '#uploadExample' //绑定元素
            , url: '/store/upload/uploadApk' //上传接口
            , accept: 'file'
            , before: function () {
                index = layer.load(1);
            }
            , done: function (res) {
                layer.close(index);
                if (res.code = 1) {
                    $("#app_path").val(res.location);
                    layer.msg('上传成功');
                } else {
                    layer.msg('上传失败');
                }
            }
            , error: function () {
                layer.close(index);
                layer.msg('上传失败');
            }
        });

        form.on('submit(t1)', function (data) {
            $.post('/store/setting.config/save', data.field, function (res) {
                if (res.code == 1) {
                    layer.msg(res.msg, { icon: 1 });
                    return false;
                }
                return layer.msg(res.msg, { icon: 2 });
            });

            return false;
        });

        form.on('submit(t2)', function (data) {
            $.post('/store/setting.config/save', data.field, function (res) {
                if (res.code == 1) {
                    layer.msg(res.msg, { icon: 1 });
                    return false;
                }
                return layer.msg(res.msg, { icon: 2 });
            });
            return false;
        });
        form.on('submit(t3)', function (data) {
            $.post('/store/setting.config/save', data.field, function (res) {
                if (res.code == 1) {
                    layer.msg(res.msg, { icon: 1 });
                    return false;
                }
                return layer.msg(res.msg, { icon: 2 });
            });
            return false;
        });
        form.on('submit(t4)', function (data) {
            $.post('/store/setting.config/save', data.field, function (res) {
                if (res.code == 1) {
                    layer.msg(res.msg, { icon: 1 });
                    return false;
                }
                return layer.msg(res.msg, { icon: 2 });
            });
            return false;
        });
        form.on('submit(t5)', function (data) {
            $.post('/store/setting.config/saveFr', data.field, function (res) {
                if (res.code == 1) {
                    layer.msg(res.msg, { icon: 1 });
                    return false;
                }
                return layer.msg(res.msg, { icon: 2 });
            });
            return false;
        });
        form.on('submit(t6)', function (data) {
            $.post('/store/setting.config/save', data.field, function (res) {
                if (res.code == 1) {
                    layer.msg(res.msg, { icon: 1 });
                    return false;
                }
                return layer.msg(res.msg, { icon: 2 });
            });
            return false;
        });
    });
</script>